package com.youshang520i.consuldiscoveryprovider.service.impl;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.youshang520i.consuldiscoveryprovider.model.Mail;
import com.youshang520i.consuldiscoveryprovider.service.RocketmqService;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;

/**
 * @author youshang
 */
@Log4j2
@Service
public class RocketmqServiceImpl implements RocketmqService {

    /**
     * 接受MQ消息
     * @param str
     * @return
     */
    @Override
    public Mail receive(String str){
        if (StrUtil.isEmpty(str)) {
            return null;
        }
        log.info("MQ接受结果 consul-discovery-provider ： "+ str);
        return JSON.parseObject(str, Mail.class);
    }

    /**
     * 广播模式测试
     * @param str
     * @return
     */
    @Override
    public Mail broadcast1(String str) {
        log.info("MQ接受结果 consul-discovery-provider ——  ：broadcast1 "+ str);
        return JSON.parseObject(str, Mail.class);
    }

    @Override
    public Mail broadcast2(String str) {
        log.info("MQ接受结果 consul-discovery-provider ——  ：broadcast2 "+ str);
        return JSON.parseObject(str, Mail.class);
    }

    @Override
    public Mail broadcast3(String str) {
        log.info("MQ接受结果 consul-discovery-provider ——  ：broadcast3 "+ str);
        return JSON.parseObject(str, Mail.class);
    }

    @Override
    public Mail broadcast4(String str) {
        log.info("MQ接受结果 consul-discovery-provider ——  ：broadcast4 "+ str);
        return JSON.parseObject(str, Mail.class);
    }


}
